package com.quanxi.qxaimain.dao.insertDemo;

import com.quanxi.qxaimain.common.datasource.datasourceAOP.annotation.DataSource;
import com.quanxi.qxaimain.common.datasource.datasourceAOP.enums.DataSourceEnum;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.ResultSetType;
import org.apache.ibatis.session.ResultHandler;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author lyx
 * @create 2022/11/17 17:31
 */
@Component
public interface insertDemoMapper {

    @DataSource(DataSourceEnum.DB5)
    Integer insert_demo(List<Map<String, Object>> list);

    /**ResultHandler测试，这里我没加参数，可以加上你的条件参数**/
  //  @DataSource(DataSourceEnum.DB1)
     void resultHandlerTest(ResultHandler<Map<String,Object>> resultHandler);

    @DataSource(DataSourceEnum.DB5)
    // Integer insert_TB_CIS_DRADVICE_DETAIL_COPY(List<Map> list);
    Integer insert_TB_CIS_DRADVICE_DETAIL_COPY(List<Map> list);


    @DataSource(DataSourceEnum.DB5)
    @Select("  SELECT  ORG_CODE,DOC_ADV_ID,INPATIENT_VISIT_FORM_NO,REVOKE_SIGN,DOC_ADV_DETAIL_NAME   FROM TB_CIS_DRADVICE_DETAIL  where  rownum<1000  ")  //参数为空 则查全部
    List<Map<String, Object>> select_TB_CIS_DRADVICE_DETAIL_COPY() ;



    @Insert("<script>" +

            "begin"+

            "<foreach collection='kLines' item='kLine' index='index' separator=';'>" +

            "insert into QXYLYSC.QX_TB_SINGLE_DISEASE_DIC_1   (DISEASE_NAME,DISEASE_CODE) " +

            "values " +

            "(#{kLine.DISEASE_NAME},#{kLine.DISEASE_CODE})" +

            "</foreach>;" +

            "end;"+

            "</script>")

    void addBatch(@Param("kLines") List<Map<String,Object>> kLines);



    @Insert("<script>" +

            "begin"+

            "<foreach collection='lists' item='data' index='index' separator=';'>" +

            "${sqlStr}"+

            "</foreach>;" +

            "end;"+

            "</script>")
    void insert(@Param("lists") List<Map<String,Object>> kLines ,@Param("sqlStr") String sql);






}
